<include file="Public/header"/>
<div class="vertical-container">
    <div class="row wrapper page-heading m-t">
        <div class="col-lg-12 panel-body" style="background: #21b9bb;color: #fff;font-size: 14px;font-weight:600">
            <span class="m-r-lg">订单编号：{$data.order_number}</span>
            <span class="m-r-lg">区域：{$data.area_name}</span>
            <span class="m-r-lg">经销商：{$data.company_name}</span>
            <span class="m-r-lg">客户名：{$data.username}</span>
            <span class="m-r-lg">电话：{$data.mobile_phone}</span>

        </div>
    </div>
</div>
<div class="wrapper " style="margin-bottom: 60px;">
    <div id="vertical-timeline" class="vertical-container light-timeline" style="margin-top: 0">

        <volist name="_list" id="vo">
            <div class="vertical-timeline-block">
                <div class="vertical-timeline-icon navy-bg">
                    <i class="fa fa-chevron-down"></i>
                </div>
                <div class="vertical-timeline-content">
                    <h2>{$vo.processname}</h2>
                    <p>{$vo.constructionworker}</p>
                    <p>{$vo.content}</p>
                   <if condition="$_GET['pid'] eq '' ">
                       <a href="{:U('Orders/cancel?fid='.$vo['fid'])}" class="btn btn-sm btn-primary m-l confirm ajax-get">取消返工</a>
                   </if>



                    <a class="btn btn-sm btn-info" data-toggle="modal" onclick="findlist({$vo.fid})"  data-target="#showfind">查看材料</a>
                    <small class="text-danger"><b>{$vo.create_at|date='Y-m-d H:i:s',###}</b></small>
                </div>
            </div>
        </volist>


        <!--查看原材料-->
        <div class="modal inmodal" id="showfind" tabindex="-1" role="dialog" aria-hidden="true">
            <form  method="post" class="form-horizontal" action="{:U('')}">
                <div class="modal-dialog modal-lg">
                    <div class="modal-content animated bounceInRight">
                        <button type="button" class="btn btn-primary btn-lg btn-noradius btn-block">原材料信息</button>
                        <input type="hidden" name="rid" value="{$rid}"/>
                        <div class="modal-body">

                            <div id="groups">

                            </div>

                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-info" data-dismiss="modal">关闭</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
        <!--添加信息按钮-->

        <if condition="$_GET['pid'] eq '' ">
            <div class="vertical-timeline-block">
                <div class="vertical-timeline-icon yellow-bg" data-toggle="modal" data-target="#addInfo">
                    <i class="fa fa-plus"></i>
                </div>
            </div>
        </if>


        <!--添加信息弹出框-->
        <div class="modal inmodal" id="addInfo" tabindex="-1" role="dialog" aria-hidden="true">
            <form  method="post" class="form-horizontal" action="{:U('')}">
                <div class="modal-dialog">
                    <div class="modal-content animated bounceInRight">
                        <button type="button" class="btn btn-primary btn-lg btn-noradius btn-block">返工操作[修改工序]</button>
                        <input type="hidden" name="rid" value="{$rid}"/>
                        <div class="modal-body">
                            <div class="form-group">
                                <label>订单工序</label>
                                <select name="pr_id" class="form-control">
                                    <option value="">请选择</option>
                                    <volist name="parr" id="vs">
                                        <option value="{$vs.pr_id}">{$vs.processname}</option>
                                    </volist>
                                </select>
                            </div>

                            <div class="form-group">
                                <label>说明</label>
                                <textarea class="form-control" name="content" rows="3" placeholder="请输入说明"></textarea>
                            </div>

                            <div class="form-group">
                                <label>需要材料</label>
                                <div class="input-group">
                                    <input type="text" class="form-control" id="search">

                                    <span class="input-group-addon search bg-info"><i class="fa "></i> 添  加</span>

                                    <div class="input-group-btn">
                                        <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                        </ul>
                                    </div>
                                </div>
                            </div>
                            <div class="groups">

                            </div>

                        </div>
                        <div class="modal-footer">
                            <button type="submit" target-form="form-horizontal" class="btn btn-primary ">提交</button>
                            <button type="button" class="btn btn-info" data-dismiss="modal">关闭</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>

</div>




<include file="Public/footer"/>
<script src="__PUBLIC__/Admin/js/bootstrap-suggest.min.js"></script>
<script src="__PUBLIC__/Admin/js/tianchen.js"></script>
<script>
    function findlist(fid) {

        $.post("{:U('Login/getdata')}",{fid:fid},function (data) {
            var  data1='';
            $.each(data,function (n,i) {
                data1+= '<div class="cailiaobox">';
                data1 += '<div class="col-xs-4"><div class="input-group m-b">';
                data1 += '<span class="input-group-addon">条码</span>';
                data1 += '<input type="text" class="form-control" readonly="readonly" value="' + i.bracode + '"></div></div>';
                data1 += '<div class="col-xs-3"><div class="input-group m-b">';
                data1 += '<span class="input-group-addon">名称</span>';
                data1 += '<input type="text" class="form-control" readonly="readonly" value="' + i.m_name + '"></div></div>';
                data1 += '<div class="col-xs-3"><div class="input-group m-b date">';
                data1 += '<span class="input-group-addon">价格</span>';
                data1 += '<input type="text" class="form-control" readonly="readonly" value="' + i.bid_price + '"></div></div>';
                data1 += '<div class="col-xs-2"><div class="input-group m-b date">';
                data1 += '<span class="input-group-addon">数量</span>';
                data1 += '<input type="text" class="form-control" readonly="readonly" value="'+i.counts+'"></div></div>';
                data1 += '<div class="clearfix"></div></div>';
            })
            $('#groups').html(data1);

        })
    }



    $('.search').click(function () {
        var keywords = $("#search").val();
        if (keywords == '') {
            layer.alert('请输入关键词');
            return;
        }
        var data = '';
        $.post("{:U('Stock/search')}", {keywords: keywords}, function (re) {
            if (re.state == 'success') {
                var info = re.info;
                data += '<div class="cailiaobox">';
                data += '<div class="col-xs-3"><div class="input-group m-b">';
                data += '<span class="input-group-addon">条码</span>';
                data += '<input type="text" class="form-control" readonly="readonly" name="bracode[]" value="' + info.bracode + '"></div></div>';
                data += '<div class="col-xs-3"><div class="input-group m-b">';
                data += '<span class="input-group-addon">名称</span>';
                data += '<input type="text" class="form-control" readonly="readonly" value="' + info.m_name + '"></div></div>';
                data += '<div class="col-xs-3"><div class="input-group m-b date">';
                data += '<span class="input-group-addon">价格</span>';
                data += '<input type="text" class="form-control" readonly="readonly" value="' + info.bid_price + '"></div></div>';
                data += '<div class="col-xs-3"><div class="input-group m-b date">';
                data += '<span class="input-group-addon">数量</span>';
                data += '<input type="text" class="form-control" name="counts[]" value="1"></div></div>';
                data += '<div class="gybtn"><span class="closebtn pull-right"><i class="glyphicon glyphicon-remove-sign text-info"></i></span></div>';
                data += '<div class="clearfix"></div></div>';
                $('.groups').append(data);
            } else {
                layer.alert('没有这个货品');
                return;
            }
        })


    });


    function initTest() {

        $("#search").bsSuggest('init', {
            allowNoKeyword: false,
            getDataMethod: 'firstByUrl',
            url: "{:U('Stock/test')}",
            idField: "userId",
            keyField: "userName"
        }).on('onDataRequestSuccess', function (e, result) {
            console.log('onDataRequestSuccess: ', result);
        }).on('onSetSelectValue', function (e, keyword, data) {
            console.log('onSetSelectValue: ', keyword, data);
        }).on('onUnsetSelectValue', function () {
            console.log('onUnsetSelectValue');
        });
    }

    initTest()

</script>